package com.ruoyi.project.zxcrm.service.impl;

import java.util.List;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.common.zx.PageData;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.zxcrm.mapper.CrmTeamMemberMapper;

/**
 * 销售团队成员Service业务层处理
 *
 * @author zx
 * @date 2023-05-30
 */
@Service
public class CrmTeamMemberServiceImpl extends BaseController{
    @Autowired
    private CrmTeamMemberMapper crmTeamMemberMapper;

    /**
     * 查询销售团队成员
     *
     * @param user_id 销售团队成员主键
     * @return pd
     */

    public PageData selectCrmTeamMemberByUser_id(Long user_id){
        return crmTeamMemberMapper.selectCrmTeamMemberByUser_id(user_id);
    }

    /**
     * 查询销售团队成员列表
     *
     * @param pd
     * @return 销售团队成员
     */

    public List<PageData> selectCrmTeamMemberList(PageData pd){
        pd.put("tenant_id",this.getUserTenantId());
        return crmTeamMemberMapper.selectCrmTeamMemberList(pd);
    }

    /**
     * 新增销售团队成员
     *
     * @param pd 销售团队成员
     * @return 结果
     */
    public int insertCrmTeamMember(PageData pd){
        pd.put("tenant_id",this.getUserTenantId());
        pd.put("update_by",this.getUsername());
        pd.put("update_time",DateUtils.getTime());
        pd.put("create_by",this.getUsername());
        pd.put("create_time",DateUtils.getTime());
        return crmTeamMemberMapper.insertCrmTeamMember(pd);
    }

    /**
     * 修改销售团队成员
     *
     * @param pd 销售团队成员
     * @return 结果
     */
    public int updateCrmTeamMember(PageData pd){
        pd.put("update_by",this.getUsername());
        pd.put("update_time",DateUtils.getTime());
        return crmTeamMemberMapper.updateCrmTeamMember(pd);
    }

    /**
     * 批量删除销售团队成员
     *
     * @param user_ids 需要删除的销售团队成员主键
     * @return 结果
     */
    public int deleteCrmTeamMemberByUser_ids(Long[] user_ids)
    {
        return crmTeamMemberMapper.deleteCrmTeamMemberByUser_ids(user_ids);
    }

    /**
     * 删除销售团队成员信息
     *
     * @param user_id 销售团队成员主键
     * @return 结果
     */
    public int deleteCrmTeamMemberByUser_id(Long user_id){
        return crmTeamMemberMapper.deleteCrmTeamMemberByUser_id(user_id);
    }
}
